using UnityEngine;
using UnityEditor;
using System.IO;

public class CreateGitKeep : MonoBehaviour
{
    [MenuItem("Assets/Create/.gitkeep",priority = 0)]
    private static void CreateGitKeepFile()
    {
        // 获取选中的文件夹路径
        string selectedFolderPath = AssetDatabase.GetAssetPath(Selection.activeObject);

        // 如果选中的是文件夹
        if (Directory.Exists(selectedFolderPath))
        {
            string gitKeepFilePath = Path.Combine(selectedFolderPath, ".gitkeep");

            // 创建空的.gitkeep文件
            File.WriteAllText(gitKeepFilePath, string.Empty);

            // 刷新Unity编辑器以显示新创建的文件
            AssetDatabase.Refresh();
        }
    }
}